home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SNNSV32.ZIP / SNNSv3.2 / kernel / sources / kr_typ.h < prev    next >
C/C++ Source or Header  |  1994-04-25  |  9KB  |  332 lines

  1. /*****************************************************************************
  2.   FILE           : kr_typ.h
  3.   SHORTNAME      : 
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : SNNS-Kernel: Datatypes and Constants for Internal Useage
  7.   NOTES          : 12.02.90
  8.  
  9.   AUTHOR         : Niels Mache
  10.   DATE           : 
  11.  
  12.   CHANGED BY     : Sven Doering, Michael Vogt
  13.   IDENTIFICATION : @(#)kr_typ.h    1.16 3/15/94
  14.   SCCS VERSION   : 1.16
  15.   LAST CHANGE    : 3/15/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.  
  19. ******************************************************************************/
  20. #include "glob_typ.h"     /*  Global datatypes and constants  */
  21. #include "ext_typ.h"     /*  Types and constants for extern kernel */
  22.  
  23. #ifndef KR_TYPES
  24. #define KR_TYPES
  25.  
  26.  
  27. /*#################################################
  28.  
  29. GROUP: Type Definitions
  30.  
  31. #################################################*/
  32.  
  33. #ifdef __BORLANDC__
  34.  
  35. #ifndef strdup
  36. #define  strdup  bsd_strdup
  37. #endif
  38.  
  39. /*
  40. #define  int long
  41. */
  42.  
  43. #endif
  44.  
  45. /*  type definition of input/output pattern array
  46. */
  47. typedef  FlintType     *Patterns;
  48.  
  49. /*  type definition of integer array for shuffeling input/output patterns
  50. */
  51. typedef  int    *PatternNumbers;
  52.  
  53. struct Unit ; /* Dummy declaration */
  54. struct Site ; /* Dummy declaration */
  55. typedef  FlintType   (* SiteFuncPtr) (struct Site *);
  56. typedef  FlintType   (* ActFuncPtr)  (struct Unit *);
  57. typedef  FlintType   (* ActDerivFuncPtr) (struct Unit *);
  58.  
  59.  
  60. /* argument type of OutFuncPtr changed from FlintType to double
  61.    due to GNU C
  62. */
  63. typedef  FlintType   (* OutFuncPtr)  (double);
  64. typedef  krui_err    (* LearnFuncPtr) (int, int, float *, int, float * *, int *);
  65. typedef  krui_err    (* UpdateFuncPtr) (float *, int);
  66. typedef  krui_err    (* InitFuncPtr) (float *, int);
  67.  
  68. /*#################################################
  69.  
  70. GROUP: Type Definition of Name Table
  71.  
  72. #################################################*/
  73.  
  74. /*  Name table structure
  75. */
  76. struct   NameTable  {
  77.   union  {
  78.     char               *symbol;             /*  stores symbol name  */
  79.     struct  NameTable  *next;               /*  stores name-table block ptr
  80.                                                 and free name-table entry   */
  81.   }  Entry;
  82.  
  83.   unsigned short       sym_type,            /*  stores type of entry   */
  84.                        ref_count;           /*  stores no. of references to
  85.                                                 this symbol (If more then MAXSHORT
  86.                                                 references are detected the symbol will
  87.                                                 released only by krm_releaseMem()
  88.                                             */
  89. };
  90.  
  91.  
  92.  
  93. /*#################################################
  94.  
  95. GROUP: Type Definition of Site-Table
  96.  
  97. #################################################*/
  98.  
  99. /*  Site table structure
  100. */
  101. struct   SiteTable  {
  102.   union  {
  103.     struct NameTable    *site_name;  /*  stores the site symbol (it's not a direkt
  104.                      pointer to the symbol, but a pointer to the
  105.                      name-table entry */
  106.     struct SiteTable    *next;         /*  stores next site-table block ptr
  107.                      and free site-table entries */
  108.   }  Entry;
  109.  
  110.   SiteFuncPtr   site_func;      /*  stores site function    */
  111. };
  112.  
  113.  
  114.  
  115. /*#################################################
  116.  
  117. GROUP: Type definition of unit functionality table
  118.  
  119. #################################################*/
  120.  
  121. /*  Unit prototype structure
  122. */
  123. struct   FtypeUnitStruct  {
  124.   struct  NameTable     *Ftype_symbol;
  125.  
  126.   OutFuncPtr      out_func;
  127.   ActFuncPtr      act_func;
  128.   ActDerivFuncPtr  act_deriv_func;
  129.  
  130.   struct Site              *sites;
  131.  
  132.   struct FtypeUnitStruct   *next;
  133.   struct FtypeUnitStruct   *prev;
  134. };
  135.  
  136.  
  137.  
  138. /*#################################################
  139.  
  140. GROUP: Unit/Site/Link type definitions
  141.  
  142. #################################################*/
  143.  
  144. /*m.r.*/
  145. /* BPTT: maximum number additional unit activity copies back in time,
  146.  (= number of non-input layers for backpropagation)
  147. */
  148. #define MAX_BPTT_BACKSTEP 10
  149.  
  150. /*  Link structure
  151. */
  152. struct   Link  {
  153.   struct Unit   *to;      /*  points to the source unit  */
  154.   FlintType     weight;   /*  link weight  */
  155.  
  156.   FlintType     value_a,  /*  general purpose elements for the  */
  157.                 value_b,  /*  learning functions  */
  158.                 value_c;
  159.  
  160.   struct Link   *next;    /*  next link  */
  161. };
  162.  
  163.  
  164. /*  Site structure
  165. */
  166. struct   Site  {
  167.   struct Link   *links;   /*  input links of the site  */
  168.   struct SiteTable      *site_table;  /*  : site name and function  */
  169.   struct Site   *next;    /*  next site  */
  170. };
  171.  
  172. /*  Type of unit flags
  173. */
  174. typedef  unsigned short  FlagWord;
  175.  
  176. /*  Unit structure
  177. */
  178. struct   Unit  {
  179.   /*  output MUST be the first element in unit structure !
  180.       (access is faster if functions can assume that <output>
  181.       is the FIRST element of the unit structure)
  182.   */
  183.   union  {
  184.     FlintType     output;       /*  unit's output  */
  185.     int           nextFreeUnit; /*  used by the unit memory manager  */
  186.   } Out;
  187.  
  188.   FlagWord        flags;        /*  unit flags  */
  189.  
  190.   int             lun;          /*  logical unit number  */
  191.   int             lln;          /*  logical layer number  */
  192.  
  193.   struct  FtypeUnitStruct   *Ftype_entry;  /*  pointer to the unit's prototype  */
  194.  
  195.   union  {
  196.     FlintType     flint_no;     /*  used by backpropagation: holds errors from successors   */
  197.     int           int_no;       /*  used by layer sorting: holds the layer no of the unit   */
  198.     char         *ptr;          /*  used for garbage collection  */
  199.   }  Aux;   /*  general purpose use  */
  200.  
  201.   struct
  202.     {
  203.     struct Unit   **my_topo_ptr;   /* pointer to coresponding entry in */
  204.                                    /* topo_ptr_array */
  205.     int           target_offset;   /* offset to prototype target unit via */
  206.                                    /* topo_ptr_array */
  207.     int           source_offset;   /* offset to logioal source unit via */
  208.                                    /* prototype target and topo_ptr_array */
  209.     int           td_connect_typ;  /* recept. field or not */
  210.     }  TD;  /* TimeDelay net datas */
  211.  
  212.   FlintType      act,        /*  current activation    */
  213.           i_act,    /*  initial activation    */
  214.           bias;     /*  bias  */
  215.  
  216.   FlintType       value_a,      /*  general purpose elements for the  */
  217.                   value_b,      /*  learning functions  */
  218.                   value_c;
  219.  
  220. /*m.r.*/
  221.   FlintType       olddelta,     /* BPTT-section: delta value at time t */
  222.                   newdelta;     /* delta value at time t-1 
  223.                    (deltas are propagated back in time )*/
  224.   FlintType       actbuf[MAX_BPTT_BACKSTEP]; /*outacts at previous time steps*/
  225. /*m.r.*/
  226.  
  227.   OutFuncPtr      out_func;        /*    output function  */
  228.   ActFuncPtr      act_func;        /*    activation function */
  229.   ActDerivFuncPtr  act_deriv_func;  /*    derivation act. function */
  230.  
  231.   char           *unit_name;    /*  unit name */
  232.  
  233.   short           subnet_no;    /*  subnet no.  */
  234.   unsigned short  layer_no;     /*  display layer (bitfield)  */
  235.  
  236.   struct PosType  unit_pos;     /*  unit position  */
  237.  
  238. #ifdef KERNEL3D
  239.   /*  unit's center position  */
  240.   struct PositionVector unit_center_pos[ NO_OF_UNIT_CENTER_POS ];
  241. #endif
  242.  
  243.   struct Site     *sites;           /*  points to unit's input links or sites  */
  244. };
  245.  
  246.  
  247.  
  248. /*#################################################
  249.  
  250. GROUP: Var types used by kernel functions
  251.  
  252. #################################################*/
  253.  
  254. /*  stucture for storing the error codes and messages of the topologic sorting
  255.     and network checking functions
  256. */
  257. struct TopologicMessages  {
  258.   int  error_code,         /*  stores the internal error code  */
  259.        no_of_cycles,       /*  no. of detected cycles in the network  */
  260.        no_of_dead_units,   /*  no. of dead units in the network  */
  261.        no_of_layers,       /*  no. of layers of the network */
  262.        dest_error_unit,    /*  first error unit (destination unit)  */
  263.        src_error_unit;     /*  first error unit (source unit)  */
  264.   char name[20];           /*  a chararcter string that can be passed */
  265. };
  266.  
  267.  
  268. /*#################################################
  269.  
  270. GROUP: Link/Site/Unit and Unit Ptrs Array Type Definitions
  271.  
  272. #################################################*/
  273.  
  274. /*  definition of link array
  275. */
  276. typedef  struct Link    *LinkArray;
  277.  
  278. /*  definition of site array
  279. */
  280. typedef  struct Site    *SiteArray;
  281.  
  282. /*  definition of pointer array for topological sorting
  283. */
  284. typedef  struct Unit *  *TopoPtrArray;
  285.  
  286. /*  definition of unit array
  287. */
  288. typedef  struct Unit    *UnitArray;
  289.  
  290. /*  Definition of Name Table Array
  291. */
  292. typedef  struct NameTable  *NTableArray;
  293.  
  294. /*  Definition of Site Name Table Array
  295. */
  296. typedef  struct SiteTable  *STableArray;
  297.  
  298.  
  299. #ifdef KERNEL3D
  300.  
  301. struct   TransTable  {
  302.   short  z,
  303.          x,
  304.      y;
  305. };
  306.  
  307. #endif
  308.  
  309. /*#################################################
  310.  
  311. GROUP: Structure Size Constants
  312.  
  313. #################################################*/
  314.  
  315. #define   UNIT_SIZE             sizeof (struct Unit)
  316. #define   SITE_SIZE             sizeof (struct Site)
  317. #define   LINK_SIZE             sizeof (struct Link)
  318.  
  319. #define   PATTERN_SIZE          sizeof (FlintType)
  320. #define   PATTERN_NO_SIZE       sizeof (int)
  321.  
  322. #define   TOPO_PTR_SIZE         sizeof (struct Unit *)
  323.  
  324. #define   NTABLE_SIZE           sizeof (struct NameTable)
  325.  
  326. #define   STABLE_SIZE           sizeof (struct SiteTable)
  327.  
  328. #define   FTYPE_UNIT_SIZE       sizeof (struct FtypeUnitStruct)
  329.  
  330.  
  331. #endif
  332.